<template>
  <el-dialog
    title="审核并打款"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-table
      :data="dataList"
      border
      style="width: 100%;"
    >
      <el-table-column prop="withDrawOrderId" header-align="center" align="center" label="提现订单号"></el-table-column>
      <el-table-column prop="nickname" header-align="center" align="center" label="用户昵称"></el-table-column>
      <el-table-column prop="idCard" header-align="center" align="center" label="身份证号"></el-table-column>
      <el-table-column prop="authenticatedPhone" header-align="center" align="center" label="实名手机号"></el-table-column>
      <el-table-column prop="alipayAccount" header-align="center" align="center" label="支付宝号"></el-table-column>
      <el-table-column prop="bankCardNumber" header-align="center" align="center" label="银行卡号"></el-table-column>
      <el-table-column prop="bankName" header-align="center" align="center" label="开户行"></el-table-column>
      <el-table-column prop="balance" header-align="center" align="center" label="提现金额"></el-table-column>
      <el-table-column prop="payFee" header-align="center" align="center" label="扣除金额"></el-table-column>
      <el-table-column prop="withdrawMethod" header-align="center" align="center" label="提现方式"></el-table-column>
      <el-table-column header-align="center" align="center" label="审核状态">
        <template slot-scope="scope">
          {{scope.row.auditStatus==1 ?'待审核':''}}
          {{scope.row.auditStatus==2 ?'打款中':''}}
          {{scope.row.auditStatus==3 ?'审核驳回':''}}
          {{scope.row.auditStatus==4 ?'打款成功':''}}
          {{scope.row.auditStatus===5 ?'打款失败':''}}
        </template>
      </el-table-column>
    </el-table>
    <el-row :gutter="20" style="display: flex;align-items: center;margin-top: 20px;">
      <el-col :span="2">备注</el-col>
      <el-col :span="22"><el-input v-model="remarks"/></el-col>
    </el-row>
    <span slot="footer" class="dialog-footer">
      <el-button  @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit('2')">确定打款</el-button>
      <el-button type="primary" @click="dataFormSubmit('3')">审核驳回</el-button>
    </span>
  </el-dialog>
</template>
<style>
  /** 去除input输入框样式 */
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
  }
  .number__input {
    border: 1px solid #ccc;
  }
</style>
<script>
  export default {
    data () {
      return {
        visible: false,
        dataList: [],
        dataForm: {
          key: "",
          rember: "",
          uid: "",
          phone:'',
          nickname:'',
        },
        id: '',
        remarks: ''
      }
    },
    methods: {
      // 获取数据列表
      getDataList (id) {
        this.remarks = ''
        this.id = id
        this.visible = true
        // 判断是单条还是多条
        if (id.indexOf(',') === -1) {
          this.$http({
            url: this.$http.adornUrl(`/account/salewithdraw/info/${id}`),
            method: "get"
          }).then(({ data }) => {
            if (data && data.code === 0) {
              this.dataList = [data.saleWithdraw]
            } else {
              this.dataList = []
            }
          })
        } else {
          const data = {
            idList: id
          }
          this.$http({
            url: this.$http.adornUrl(`/account/salewithdraw/info/list`),
            method: "post",
            params: this.$http.adornParams(data)
          }).then(({ data }) => {
            if (data && data.code === 0) {
              this.dataList = data.saleWithdraw
            } else {
              this.dataList = []
            }
          })
        }
      },
      // 表单提交
      dataFormSubmit (status) {
        const data = {
          ids: this.id,
          remarks: this.remarks,
          auditResult: status,
          auditAdminId: JSON.parse(window.localStorage.getItem('userInfo')).userId.toString()
        }
        this.$http({
          url: this.$http.adornUrl(`/account/salewithdraw/update`),
          method: 'post',
          params: this.$http.adornParams(data)
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.visible = false
                this.$emit('refreshDataList')
              }
            })
          } else {
            this.$message.error(data.msg)
            this.visible = false
          }
        })
      }
    }
  }
</script>
